home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / folder watching / fw receiver / initialize.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.4 KB  |  134 lines

  1. /*
  2.     File:        Initialize.c
  3.  
  4.     Contains:    Initialization code for this application
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. #pragma segment Initialize
  24.  
  25.  
  26.  
  27. // System includes
  28.  
  29. #ifndef __QUICKDRAW__
  30.     #include <Quickdraw.h>
  31. #endif
  32.  
  33. #ifndef __FONTS__
  34.     #include <Fonts.h>
  35. #endif
  36.  
  37. #ifndef __TEXTEDIT__
  38.     #include <TextEdit.h>
  39. #endif
  40.  
  41. #ifndef __DIALOGS__
  42.     #include <Dialogs.h>
  43. #endif
  44.  
  45. #ifndef __GESTALT__
  46.     #include <Gestalt.h>
  47. #endif
  48.  
  49. #ifndef __SEGLOAD__
  50.     #include <SegLoad.h>
  51. #endif
  52.  
  53.  
  54.  
  55.  
  56. // Application includes
  57.  
  58. #ifndef __BAREBONES__
  59.     #include "BareBones.h"
  60. #endif
  61.  
  62. #ifndef __PROTOTYPES__
  63.     #include "Prototypes.h"
  64. #endif
  65.  
  66.  
  67.  
  68. // static prototypes
  69. static Boolean CheckConfiguration ( void );
  70.  
  71.  
  72.  
  73.  
  74. void InitToolbox ( void )
  75. {    
  76.     
  77.     InitGraf ( &qd.thePort );
  78.     InitFonts ( );
  79.     InitWindows ( );
  80.     InitMenus ( );
  81.     TEInit ( );
  82.     InitDialogs ( nil );
  83.     InitCursor ( );
  84.     
  85.     FlushEvents ( everyEvent, 0 );
  86.     
  87.     return;
  88. }
  89.  
  90.  
  91.  
  92. void InitApplication ( void )
  93. {
  94.     SetMenuBar ( GetNewMBar ( kMenuBarID ) );
  95.     AppendResMenu ( GetMenuHandle ( kAppleMenu ), 'DRVR' );
  96.     DrawMenuBar ( );
  97.     
  98.     if ( !CheckConfiguration ( ) )
  99.     {
  100.         AlertUser ( kNeedSystem7, 0, nil );
  101.         ExitToShell ( );
  102.     }
  103.     
  104.     gQuit = false;                          // Initialize flag that controls main event loop
  105.     gSleepTime = kSleepTime;
  106.     
  107.     InstallAppleEventHandlers ( );
  108.     CreateWindow ( );
  109.     
  110.     return;
  111. }
  112.  
  113.  
  114.  
  115. static Boolean CheckConfiguration ( void )
  116. {
  117.     long        theResult;
  118.     OSErr        theErr;
  119.     Boolean        bHasAppleEvents;
  120.     
  121.     
  122.     // Verify that we can run on the current configuration
  123.     
  124.     // We require AppleEvent Manager and FSSpec-based file traps and Standard File
  125.     theErr = Gestalt ( gestaltAppleEventsAttr, &theResult );
  126.     bHasAppleEvents = (theErr == noErr && (theResult & (1L << gestaltAppleEventsPresent)));
  127.     
  128.     return bHasAppleEvents;
  129. }
  130.  
  131.  
  132.  
  133.  
  134.